package com.middlegroup.payadmin.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.middlegroup.payadmin.mapper.SubjectChannelsMapper;
import com.middlegroup.payadmin.pojo.dto.ChannelsDto;
import com.middlegroup.payadmin.pojo.dto.DataGrid;
import com.middlegroup.payadmin.pojo.po.Channels;
import com.middlegroup.payadmin.pojo.po.SubjectChannels;
import com.middlegroup.payadmin.service.SubjectChannelsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 主体通道表 服务实现类
 * </p>
 *
 * @author pc123
 * @since 2019-01-04
 */
@Service
public class SubjectChannelsServiceImpl extends ServiceImpl<SubjectChannelsMapper, SubjectChannels> implements SubjectChannelsService {

    @Resource
    private SubjectChannelsMapper subjectChannelsMapper;


    @Override
    public PageInfo<SubjectChannels> getSubjectChannelsByPayType(DataGrid grid,String subjectCode, Long serviceParType) {
        //grid.getOrderBy();
        return PageHelper.startPage(grid.getPageNum(), grid.getPageSize())
                .doSelectPageInfo(() -> this.subjectChannelsMapper.getSubjectChannelsByParType(subjectCode,serviceParType));
    }

    @Override
    public List<Channels> waitChannelsList(String serviceType,String subjectCode) {
        return subjectChannelsMapper.waitChannelsList(serviceType,subjectCode);
    }

    @Override
    public int saveOrUpdate(SubjectChannels subjectChannels) {
        return subjectChannelsMapper.saveOrUpdate(subjectChannels);
    }

    @Override
    public List<ChannelsDto> getChannelsBySubjectCode(String serviceType, String subjectCode,String merchantCode) {
        return subjectChannelsMapper.getChannelsBySubjectCode(serviceType,subjectCode,merchantCode);
    }
}
